#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
const int MAXN=1e6;
ll POW(ll a, ll b) {
	ll res=1;
	ll z=a;
	while (b) {
		if (b&1) {
			res=(res*z)%MOD;
		}
		z=(z*z)%MOD;
		b=b>>1;
	}
	return res;
}
ll fac[MAXN];
ll refac[MAXN];
void Init() {
	fac[1]=1;
	refac[1]=1;
	for (int i=2; i<MAXN; ++i) {
		fac[i]=(fac[i-1]*i)%MOD;
		refac[i]=POW(fac[i], MOD-2)%MOD;
	}
}
ll C(ll n, ll r) {
	ll res=(((fac[n]*refac[r])%MOD)*refac[n-r])%MOD;
	if (res<0) res+=MOD;
	return res;
}
int main() {
	Init();
	ll n,r;
	while (cin>>n>>r) {
		cout<<C(n,r)<<endl;
	}
	return 0;
}
